package com.itheima.service.impl;

import com.itheima.dao.BookMapper;
import com.itheima.domain.Book;
import com.itheima.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class BookServiceImpl implements BookService {
    @Autowired
    private BookMapper bookMapper;

    public Book findBookById(Integer id) {
        return bookMapper.findBookById(id);
    }

    @Override
    public boolean addBook(Book book) {
        return bookMapper.addBook(book);
    }

    @Override
    public List<Book> findAllBook() {
        return bookMapper.findAllBook();
    }

    @Override
    public boolean changeBook(Book book) {
        return bookMapper.updateBook(book);
    }

    @Override
    public boolean deleteBook(Integer id) {
        return bookMapper.deleteBook(id);
    }

    @Override
    public List<Book> findBookByNameAndAuthorAndPrice(String bookName, String author, String minPrice, String maxPrice) {
        return bookMapper.searchBook( bookName,  author,  minPrice,  maxPrice);
    }
}

